﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing;

namespace V.Utility
{
    public class Converter
    {
        //转换图片为byte[]
        public static byte[] ConvertImageToByte(Image img, System.Drawing.Imaging.ImageFormat format)
        {
            MemoryStream ms = new MemoryStream();
            img.Save(ms, format);
            byte[] bytes = ms.ToArray();
            ms.Close();
            return bytes;
        }

        //转换byte[]为图片
        public static Image ConvertByteToImage(byte[] bytes)
        {
            MemoryStream ms = new MemoryStream(bytes);
            Image img = Image.FromStream(ms, true);
            ms.Close();
            return img;
        }
    }
}
